package com.szgr.baoyin.activity;

import android.graphics.drawable.Drawable;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.szgr.baoyin.R;
import com.szgr.baoyin.fragment.BrandLeftFragment;
import com.szgr.baoyin.fragment.BrandRightFragment;

/**
 * 旧的首页保银品牌
 */
public class BaoYinBrandActivity extends BaseActivity implements RadioGroup.OnCheckedChangeListener {

    private FragmentManager manager;
    private RadioButton rb_left;
    private RadioButton rb_right;
    private BrandLeftFragment leftFragment;
    private BrandRightFragment rightFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_bao_yin_brand);
        super.onCreate(savedInstanceState);
    }

    @Override
    public void initActionBar() {
        actionBarTitle.setText("保银品牌");
    }

    @Override
    public void initView() {
        manager = getSupportFragmentManager();
        RadioGroup rg_brand = (RadioGroup) findViewById(R.id.brand_radio_group);
        rg_brand.setOnCheckedChangeListener(this);
        rb_left = (RadioButton) findViewById(R.id.brand_left);
//        rb_left.setOnClickListener(this);
        rb_right = (RadioButton) findViewById(R.id.brand_right);
//        rb_right.setOnClickListener(this);
        leftFragment = new BrandLeftFragment();
        rightFragment = new BrandRightFragment();
        rb_left.setChecked(true);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.action_bar_left:
                finish();
                break;
        }
    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        switch (checkedId){
            case R.id.brand_left:
                rb_left.setTextColor(0xff234b64);
                rb_right.setTextColor(0xffffffff);
                FragmentTransaction leftTransaction = manager.beginTransaction();
                leftTransaction.replace(R.id.brand_container, leftFragment);
                leftTransaction.commit();
                break;
            case R.id.brand_right:
                rb_left.setTextColor(0xffffffff);
                rb_right.setTextColor(0xff234b64);
                FragmentTransaction rightTransaction = manager.beginTransaction();
                rightTransaction.replace(R.id.brand_container, rightFragment);
                rightTransaction.commit();
                break;
        }
    }
}
